package com.example.hanchen.yongkanggy.home.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.hanchen.yongkanggy.R;
import com.example.hanchen.yongkanggy.home.activity.InspectionDetailsActivity;
import com.example.hanchen.yongkanggy.home.activity.SettingActivity;
import com.example.hanchen.yongkanggy.home.adapter.ControlitemAdapter;
import com.example.hanchen.yongkanggy.home.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

public class ControlitemFragment extends BaseFragment {
    TextView tv_name;
    int mParam;

    RecyclerView rv_list;
    ControlitemAdapter controlitemAdapter;

    List<String> stringList = new ArrayList<>();

    public static ControlitemFragment newInstance(int mParam) {//int typePosition
        Bundle args = new Bundle();
        ControlitemFragment fragment = new ControlitemFragment();
        args.putInt("mParam", mParam);
        fragment.setArguments(args);
        return fragment;
    }

    @SuppressLint("MissingInflatedId")
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_control_item, container, false);
        rv_list = view.findViewById(R.id.rv_list);


        for (int i = 0; i < 5; i++) {
            stringList.add("");
        }

        if (getArguments() != null) {
            mParam = getArguments().getInt("mParam");
        }

        controlitemAdapter = new ControlitemAdapter(getActivity(), new ControlitemAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                startActivity(new android.content.Intent(getActivity(), InspectionDetailsActivity.class));
            }
        });
        rv_list.setLayoutManager(new LinearLayoutManager(getActivity()));
        rv_list.setAdapter(controlitemAdapter);
        controlitemAdapter.setTabData(stringList);

        return view;
    }
}
